<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/


/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function () {

//    Route::get('/', function () {
//        return view('welcome');
//    });
    //前台视图路由
    Route::get('/','Home\IndexController@index');
    //前台分类路由
    Route::get('/cate/{cate_id}','Home\IndexController@cate');
    //前台文章路由
    Route::get('/a/{art_id}', 'Home\IndexController@news');
    Route::get('/test', 'Home\IndexController@qrcode');
    
    //Route::get('/news','Home\IndexController@news');


    //后台登录路由
    Route::any('admin/login','Admin\LoginController@login');
    //后台登录时验证码路由
    Route::get('admin/code','Admin\LoginController@code');

});

Route::group(['middleware' => ['web','admin.login'],'prefix'=>'admin','namespace'=>'Admin' ], function () {
    //后台修改密码功能路由
    Route::any('pass','IndexController@pass');
    //后台主页面路由
    Route::get('index','IndexController@index');
    //后台info页面路由
    Route::get('info','IndexController@info');

    //后台退出路由
    Route::get('quit','LoginController@quit');

    //分类添加路由
    Route::get('category/create','CategoryController@create');
    //分类排序功能ajax异步修改排序路由
    Route::post('category/changeorder','CategoryController@changeOrder');
    //分类资源路由
    Route::resource('category', 'CategoryController');


    //文章路由
    Route::resource('article', 'ArticleController');


    //友情链接路由
    Route::resource('links', 'LinksController');
    //友情链接排序功能ajax异步修改排序路由
    Route::post('links/changeorder','LinksController@changeOrder');

    //自定义导航路由
    Route::resource('navs', 'NavsController');
    //自定义导航排序功能ajax异步修改排序路由
    Route::post('navs/changeorder','NavsController@changeOrder');


    //配置项路由
    Route::resource('config', 'ConfigController');
    //配置index界面表单提交
    Route::post('config/changecontent','ConfigController@changeContent');

    //把配置项写入到config目录下的配置文件
    Route::get('config/getfile','ConfigController@show');

    //配置项排序功能ajax异步修改排序路由
    Route::post('config/changeorder','ConfigController@changeOrder');

    //图片上传
    Route::any('upload','CommonController@upload');
});
